package com.haizhi.crm.sys.configure.model;

import com.haizhi.crm.sys.configure.constant.ModuleSettingCategory;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Optional;


/**
 * 传给页面显示用户自定义模块的vo
 * Created by caochao on 2018/05/31.
 */
@ApiModel(description = "用户自定义模块的属性分组，每一组" )
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserModuleSettingCategoryVo {


    @ApiModelProperty("分组的code，取值如下（name : 自定义名称，data_range : 数据显示范围，field：显示字段， page_szie:分页条数）" )
    private String categoryCode;

    @ApiModelProperty("分组的名称，与categoryCode对应" )
    private String categoryName;

    @ApiModelProperty("这一组所包含的自定义元素" )
    private List<UserModuleSettingItemVo> items;

    public UserModuleSettingCategoryVo(String categoryCode, List<UserModuleSettingItemVo> items) {
        this.categoryCode = categoryCode;
        this.items = items;
        this.categoryName = Optional.of(ModuleSettingCategory.codeOf(categoryCode)).map(u -> u.getName()).orElse(null);
    }

}


